use core::{cell::UnsafeCell, mem::MaybeUninit, slice};


unsafe impl<const SIZE: usize> Sync for ByteBuffer<SIZE> {}
unsafe impl<const SIZE: usize> Send for ByteBuffer<SIZE> {}

#[repr(align(8))]
pub struct ByteBuffer<const SIZE: usize> {
    _mem: UnsafeCell<MaybeUninit<[u8; SIZE]>>,
}

impl<const SIZE: usize> ByteBuffer<SIZE> {
    pub const fn const_new() -> Self {
        Self {
            _mem: UnsafeCell::new(MaybeUninit::uninit()),
        }
    }

    pub const fn size(&self) -> usize {
        SIZE
    }

    pub const fn as_ptr(&self) -> *const u8 {
        self as *const Self as _
    }

    pub const fn as_mut_ptr(&self) -> *mut u8 {
        self.as_ptr() as _
    }

    pub const unsafe fn as_mut_slice(&self) -> &mut [u8] {
        slice::from_raw_parts_mut(self.as_mut_ptr(), SIZE)
    }
}